package com.isoftstone.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.isoftstone.entity.CK_Prescription;
import com.isoftstone.entity.C_Prescription;
import com.isoftstone.entity.Patient;
import com.isoftstone.entity.W_Prescription;
import com.isoftstone.service.RefundService;
@Controller
@RequestMapping("refund")
public class RefundController {
	private String guahao_id;
	@Autowired
	private RefundService refundService;
	
	@RequestMapping("RefundList")
	public String openRefund(ModelMap modelMap){

		return "RefundList";
	}
	
	@RequestMapping("getPatient")
	@ResponseBody
	public List<Patient> getPatient(String patient_name,String patient_idcard){
		List<Patient> patient = refundService.getPatient(patient_name,patient_idcard);
		guahao_id = patient.get(0).getGuahao_id();
		return patient;
	}
	
	@RequestMapping("getCkPrescription")
	@ResponseBody
	public List<CK_Prescription> getCkPrescription() {
		List<CK_Prescription> cklist = refundService.getCkPrescription(guahao_id);
		return cklist;
	}
	
	@RequestMapping("getWmPrescription")
	@ResponseBody
	public List<W_Prescription> getWmPrescription() {
		List<W_Prescription> wmlist = refundService.getWmPrescription(guahao_id);
		return wmlist;
	}
	
	@RequestMapping("getCmPrescription")
	@ResponseBody
	public List<C_Prescription> getCmPrescription() {
		List<C_Prescription> cmlist = refundService.getCmPrescription(guahao_id);
		return cmlist;
	}
	
	@RequestMapping("ckRefund")
	@ResponseBody
	public void kRefund(Double ck_amount_refund,String ck_id,Date ls_data){			
			refundService.ckRefund(ck_amount_refund,ck_id,guahao_id);
			refundService.insertFee(ck_id,ck_amount_refund,ls_data);
		}
	
	@RequestMapping("cmRefund")
	@ResponseBody
	public void cRefund(Double cm_amount_refund,String cm_id,Date ls_data){
		refundService.cmRefund(cm_amount_refund,cm_id,guahao_id);
		refundService.insertFee(cm_id,cm_amount_refund,ls_data);
	}
	
	@RequestMapping("wmRefund")
	@ResponseBody
	public void wRefund(Double wm_amount_refund,String wm_id,Date ls_data){
		refundService.wmRefund(wm_amount_refund,wm_id,guahao_id);
		refundService.insertFee(wm_id,wm_amount_refund,ls_data);
	}
}
